package com.tjl.yangxixis.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.lyp.activitys.OpinionActivity;
import com.lyp.jsonbean.LoginBean;
import com.tjl.yangxixis.OriginalFragment;
import com.tjl.yangxixis.R;
import com.tjl.yangxixis.activity.ClauseActivity;
import com.tjl.yangxixis.activity.MainActivity;
import com.tjl.yangxixis.activity.PersonageMessageActivity;
import com.tjl.yangxixis.activity.ProceduresActivity;

/**
 *
 * @author Administrator
 *   销售员经理
 */
public class JlMyFragment extends OriginalFragment implements OnClickListener{


	View v;
	private RelativeLayout mServiceManual,mUseClauses,mFeedback,mAbout,mVersion;
	private LinearLayout mMessage;
	private LoginBean.DataBean bean;
	private TextView mName;

	@Override
	protected void lazyLoad() {
	}

	public View createView(LayoutInflater inflater, ViewGroup container,
						   Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		v=inflater.inflate(R.layout.fragment_jlmy, null);
		init();
		return v;
	}

	private void init(){
		bean = ((MainActivity)getActivity()).dataBean;
		mMessage = (LinearLayout) v.findViewById(R.id.ll_jlmy_message);
		mServiceManual = (RelativeLayout) v.findViewById(R.id.rl_jlmy_service_manual);
		mUseClauses = (RelativeLayout) v.findViewById(R.id.rl_jlmy_use_clauses);
		mFeedback = (RelativeLayout) v.findViewById(R.id.rl_jlmy_feedback);
		mAbout = (RelativeLayout) v.findViewById(R.id.rl_jlmy_about);
		mVersion = (RelativeLayout) v.findViewById(R.id.rl_jlmy_version);
		mName = (TextView) v.findViewById(R.id.name);
		mMessage.setOnClickListener(this);
		mServiceManual.setOnClickListener(this);
		mUseClauses.setOnClickListener(this);
		mFeedback.setOnClickListener(this);
		mAbout.setOnClickListener(this);
		mVersion.setOnClickListener(this);
		mName.setText(bean.getUser());
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		Intent intent;
		switch (arg0.getId()) {
			case R.id.ll_jlmy_message:
				intent = new Intent(getActivity(),PersonageMessageActivity.class);
				Bundle bundle = new Bundle();
				bundle.putSerializable("databean",bean);
				intent.putExtras(bundle);
				startActivity(intent);
				break;
			case R.id.rl_jlmy_service_manual:
				intent = new Intent(getActivity(),ProceduresActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_jlmy_use_clauses:
				intent = new Intent(getActivity(), ClauseActivity.class);
				startActivity(intent);
				break;
			//反馈
			case R.id.rl_jlmy_feedback:
				intent = new Intent(getActivity(), OpinionActivity.class);
				Bundle bundles = new Bundle();
				bundles.putSerializable("databean",bean);
				intent.putExtras(bundles);
				startActivity(intent);
				break;
			case R.id.rl_jlmy_about:
				ToastUtils.showShort("关于我们");
				break;
			case R.id.rl_jlmy_version:
				ToastUtils.showShort("当前版本");
				break;
		}
	}
}
